/*
 * @(#)FormSelectionSqlValues.java
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */

package com.dcivision.form.bean;

import java.util.ArrayList;
import java.util.List;

import com.dcivision.framework.Utility;

/**
FormSelectionSqlValues.java

This class is the values of the elements(i.e. selection/radio/checkBox) from DB look .

  @author           Charlie liu
  @company          DCIVision Limited
  @creation date    12/09/2006
  @version          $Revision: 1.3 $
*/

public class FormDBlookupSQL {
	
	public static final String REVISION = "$Revision: 1.3 $";
	
	private String field;
	
	private String table;
	
	private String condition;
	
	private List sqlResult=new ArrayList();
	
	public FormDBlookupSQL(){
		field="";
		table="";
		condition="";
	}
	public FormDBlookupSQL(String field,String table,String condition){
		this.field=field;
		this.table=table;
		this.condition=condition;
	}
	public FormDBlookupSQL(String field,String table){		
		this.field=field;
		this.table=table;
		this.condition=null;		
	}
	
	public void setField(String field){
		this.field=field;
	}
	public String getField(){
		return this.field;
	}
	
	public void setTable(String table){
		this.table=table;
	}
	public String getTable(){
		return this.table;
	}
	
	public void setCondition(String condition){
		this.condition=condition;
	}
	public String getCondition(){
		return this.condition;
	}
	
	public void setSqlResult(List list){
		this.sqlResult=list;
	}
	public List getSqlResult(){
		return this.sqlResult;
	}
	
	public String validator(){		
		if(Utility.isEmpty(field)||Utility.isEmpty(table)){
			return new String("error");
		}else{
			if (//field.indexOf(",")>=0 ||
					//field.trim().indexOf(" ")>=0 || 
					field.indexOf("*")>=0 ||
					field.split(",").length > 2 ||
					table.indexOf(",")>=0 || 
					table.trim().indexOf(" ")>=0){
				return new String("error");	
		  }else{
		  	return new String("success");
		  }			
		}
	}
}